/*
 * GPIO.c
 *
 *  Created on: Sep 18, 2014
 *      Author: Administrador
 */

#include "GPIO.h"


void vfn_GPIO_INIT(void){
	/*Config the Ports*/
	
	PORTE_PCR26 = PORT_PCR_MUX(eGPIO);//Config as IO
	PORTB_PCR21 = PORT_PCR_MUX(eGPIO);//Config as IO
	PORTB_PCR22 = PORT_PCR_MUX(eGPIO);//Config as IO
	GPIOB_PDDR = (SET << BLUE)|(SET << RED); //As Output
	GPIOE_PDDR = (SET << GREEN);//As Output
	GPIOB_PTOR = (SET<<BLUE)|(SET<<RED);//Toggle
	GPIOE_PTOR = (SET<<GREEN);//Toggle
}


void vfn_RGB_led(eRGB_t eLED){
	if (eLED == _Red)	GPIOB_PTOR = (SET<<RED);//Toggle
	else if (eLED == _Green)	GPIOE_PTOR = (SET<<GREEN);//Toggle
	else if (eLED == _Blue)		GPIOB_PTOR = (SET<<BLUE);//Toggle
	else{
		GPIOB_PTOR = (SET<<BLUE)|(SET<<RED);//Toggle
		GPIOE_PTOR = (SET<<GREEN);//Toggle
	}
	
}

void vfn_RGBRed_led(void){
	GPIOB_PTOR = (CLEAR<<BLUE)|(SET<<RED);//Toggle
	GPIOE_PTOR = (CLEAR<<GREEN);//Toggle
}

void vfn_RGBGreen_led(void){
	GPIOB_PTOR = (CLEAR<<BLUE)|(CLEAR<<RED);//Toggle
	GPIOE_PTOR = (SET<<GREEN);//Toggle
}

void vfn_RGBBlue_led(void){
	GPIOB_PTOR = (SET<<BLUE)|(CLEAR<<RED);//Toggle
	GPIOE_PTOR = (CLEAR<<GREEN);//Toggle
}
